package org.adit.spring.hibernate.parser;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.util.Scanner;

public class SPReport {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		getPage();

		
		
		//String ref = readLatLonId(id);

		// writeFile(page);

	}

	
	
	public static String readLatLonId(String id) {
		try {
			Scanner scanner;

			scanner = new Scanner(new FileInputStream("c:/latlonidManaus.txt"));

			String ret = "";
			
			while (scanner.hasNextLine()) {

				scanner.useDelimiter(",");
				String ident = scanner.next();
				String x = scanner.next();
				String y = scanner.next();
				
				if(ident.equalsIgnoreCase(id)){
					//ret = 
				}
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return id;
	}

	public static String getPage() {
		String site = "";

		try {

			FileInputStream fstream = new FileInputStream("c:/oia.html");
			// Get the object of DataInputStream
			DataInputStream in = new DataInputStream(fstream);
			BufferedReader br = new BufferedReader(new InputStreamReader(in));
			String strLine;
			// Read File Line By Line
			while ((strLine = br.readLine()) != null) {
				// Print the content on the console
				site = site + " " + strLine;
				System.out.println(strLine);
			}
			// Close the input stream
			in.close();

		} catch (Exception e) {// Catch exception if any
			System.err.println("Error: " + e.getMessage());
		}
		return site;
	}

	public static void writeFile(String page) {
		try {
			// Create file
			FileWriter fstream = new FileWriter("out.html");
			BufferedWriter out = new BufferedWriter(fstream);
			out.write("Hello Java");
			// Close the output stream
			out.close();
		} catch (Exception e) {// Catch exception if any
			System.err.println("Error: " + e.getMessage());
		}
	}

}
